package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingAppNotice;
import com.ruoyi.ring.service.IRingAppNoticeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * app消息Controller
 * 
 * @author liuwp
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/ring/ring_app_notice")
public class RingAppNoticeController extends BaseController
{
    @Resource
    private IRingAppNoticeService ringAppNoticeService;

    /**
     * 查询app消息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingAppNotice ringAppNotice)
    {
        startPage();
        List<RingAppNotice> list = ringAppNoticeService.selectRingAppNoticeList(ringAppNotice);
        return getDataTable(list);
    }

    /**
     * 导出app消息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:export')")
    @Log(title = "app消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingAppNotice ringAppNotice)
    {
        List<RingAppNotice> list = ringAppNoticeService.selectRingAppNoticeList(ringAppNotice);
        ExcelUtil<RingAppNotice> util = new ExcelUtil<RingAppNotice>(RingAppNotice.class);
        util.exportExcel(response, list, "app消息数据");
    }

    /**
     * 获取app消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:query')")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable("noticeId") Integer noticeId)
    {
        return AjaxResult.success(ringAppNoticeService.selectRingAppNoticeByNoticeId(noticeId));
    }

    /**
     * 新增app消息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:add')")
    @Log(title = "app消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingAppNotice ringAppNotice)
    {
        return toAjax(ringAppNoticeService.insertRingAppNotice(ringAppNotice));
    }

    /**
     * 修改app消息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:edit')")
    @Log(title = "app消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingAppNotice ringAppNotice)
    {
        return toAjax(ringAppNoticeService.updateRingAppNotice(ringAppNotice));
    }

    /**
     * 删除app消息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_app_notice:remove')")
    @Log(title = "app消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeIds}")
    public AjaxResult remove(@PathVariable Integer[] noticeIds)
    {
        return toAjax(ringAppNoticeService.deleteRingAppNoticeByNoticeIds(noticeIds));
    }
}
